'use strict';
require('module-alias/register');
/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = appInfo => {
  /**
   * built-in config
   * @type {Egg.EggAppConfig}
   **/
  const config = exports = {};

  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_1607497533194_552';

  config.auth = {
    exclude: [ '/v1/user/login', '/v1/user/register' ],
  };

  // middleware文件夹下的文件配置位置--中间件
  // config.middleware = [  ];

  config.security = {
    csrf: {
      enable: false,
    },
  };

  config.sequelize = {
    dialect: 'mysql',
    host: '127.0.0.1',
    port: 3306,
    user: 'root',
    password: 'q350413177',
    database: 'tourism_shop',
    define: {
      timestamps: false,
      freezeTableName: true,
    },
    timezone: '+8:00',
  };

  config.jwt = {
    secret: '1169655050@qq.com',
  };

  config.redis = {
    client: {
      port: 6379,
      host: '127.0.0.1',
      password: 'q350413177',
      db: 0,
    },
  };

  // 访问源限制
  config.allowHosts = [ '127.0.0.1:8000', 'localhost:8000' ];

  // 访问间隔时间（毫秒）和次数
  config.interfaceLimit = {
    maxCount: 5,
    time: 3 * 1000,
  };

  // 接口缓存时间（秒）
  config.interfaceCache = {
    expiresIn: 10,
    include: [ 'POST /v1/user/detail' ],
  };

  // add your user config here
  const userConfig = {
    expiresIn: 60 * 60 * 2,
  };

  return {
    ...config,
    ...userConfig,
  };
};
